<template>
	<view>
		<view style="width:100%;">
			<Tabs :tabs="tabs" @change="tabsIndex"></Tabs>
		</view>
		<view v-for="(a_item,a_index) in lists" :key="a_index" class="bw-price-lists">
			<view>
				<text class="bw-text-block">{{a_item.order_no}}</text>
				<text class="bw-text-time">{{a_item.create_time}}</text>
			</view>
			<view class="bw-price">
				<text>+{{a_item.amount}}</text>
			</view>
		</view>
		<view class="bw-Empty" v-if="Switch == true">
			<Empty></Empty>
		</view>
		<loading :loading="loading"></loading>
	</view>
</template>

<script>
	import Empty from 'components/bw-Empty/bw-Empty';
	import Tabs from 'components/bw-Tabs/bw-Tabs';
	import loading from 'components/bw-loading/bw-loading';
	import {withdrawal} from '../../../api/share.js';
	export default {
		components:{
			Empty,
			Tabs,
			loading
		},
		data(){
			return{
				tabs:[
					{name:'全部'},
					{name:'收入'},
					{name:'支出'},
					],
				lists:[],
				total:0,
				req:{
					order_no:'',
					page:1,
					limit:10
				},
				loading:false, //true加载完成 false未加载完成
				Switch:false
			}
		},
		//下拉加载
		onReachBottom() {
			if(this.lists.length < this.total){
				this.req.page +=1;
				this.withdrawal();
				this.loading = false;
			}else{
				this.loading = true;
			}
		},
		mounted() {
			this.withdrawal();
		},
		methods:{
			tabsIndex(e){
				console.log(e);
			},
			//提现明细
			async withdrawal(){
				const res = await withdrawal(this.req);
				this.total = res.data.total;
				this.lists = res.data.data;
				this.lists.length < this.total ? this.loading = false : this.loading = true;
				this.lists.length > 0 ? this.Switch = false : this.Switch = true;
				console.log(res);
			}
		}
	}
</script>

<style>
	page{background-color:#f5f7f6;}
</style>

<style scoped lang="less">
	page{background-color:#f5f7f6;}
	
	.bw-Empty{
		margin-top:30rpx;
	}
	
	.bw-price-lists{
		width:95%;
		margin:20rpx auto;
		background-color:#FFFFFF;
		display: flex;
		justify-content: space-between;
		.bw-text-block{
			display: block;
			font-size:30rpx;
			padding:20rpx;
		}
		.bw-text-time{
			font-size:28rpx;
			display: block;
			padding-left:20rpx;
			padding-bottom:20rpx;
			color:#959595;
		}
		text{
			color:#000000;
			padding-left:10rpx;
		}
		.bw-price{
			display: flex;
			align-items: center;
			text{
				padding-right:20rpx;
				color:#e79f2b;
				font-weight:500;
			}
		}
	}
</style>
